import Request from './axios';
import Config from './config';
import local from '@/utils/localStorage';

export default new Request({
  baseURL: Config.baseUrl,
  timeout: Config.timeout,
  interceptors: {
    requestInterceptor: (config) => {
      // 携带token的拦截
      const token = local.get('token');
      if (token) {
        config.headers.Authorization = token;
      }
      return config;
    },
    requestInterceptorCatch: (err) => {
      return err;
    },
    responseInterceptor: (res) => {
      return res;
    },
    responseInterceptorCatch: (err) => {
      return err;
    }
  }
});
